package com.brillilab.service.core.kit.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.brillilab.dao.mapper.kit.ReagentAntibodyMapper;
import com.brillilab.domain.po.kit.KitSpec;
import com.brillilab.domain.po.kit.ReagentAntibody;
import com.brillilab.service.core.kit.IReagentAntibodyService;

@Service
@Transactional
public class ReagentAntibodyServiceImpl implements IReagentAntibodyService{
	
	@Autowired
	private ReagentAntibodyMapper reagentAntibodyMapper;	

	@Override
	public ReagentAntibody insert(ReagentAntibody entity) {
		Integer insert = reagentAntibodyMapper.insert(entity);
		Assert.isTrue(insert==1, "添加失败");
		return entity;
	}
	
	@Override
	public boolean deleteById(Long id) {
		Integer b = reagentAntibodyMapper.deleteById(id);
		return b==1 ? true: false;
	}
	
	@Override
	public boolean updateById(ReagentAntibody entity) {
		entity.setUpdateTime(new Date());
		Integer b = reagentAntibodyMapper.updateById(entity);
		return b==1 ? true: false;
	}
	
	@Override
	public ReagentAntibody selectById(Long id) {
		return reagentAntibodyMapper.selectById(id);
	}

	@Override
	public ReagentAntibody selectOne(Long kitId,Long reagentId) {
		LambdaQueryWrapper<ReagentAntibody> wrapper = new LambdaQueryWrapper<>();
		wrapper.eq(ReagentAntibody::getKitId,kitId);
		wrapper.eq(ReagentAntibody::getReagentId,reagentId);
		return reagentAntibodyMapper.selectOne(wrapper);
	}
}
